﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>

    <link rel="stylesheet" href="~/css/metro-bootstrap.css">
    <script type="text/javascript" src="~/js/own.js"></script>
    <script src="~/js/jquery.min.js"></script>
    <script src="~/js/jquery.widget.min.js"></script>
    <script src="~/js/metro.min.js"></script>

</head>
<body class="metro" style="background-color: rgb(239, 234, 227);">
    <div class="container" style="display: block; margin: 0 auto">
        <div class="navigation-bar dark fixed-top shadow">
            <div class="navigation-bar-content container">
                <a href="/" class="element">
                    <span>"BOOKING TICKET ONLINE"
                    </span>
                    <sub>1.0
                    </sub>
                </a>
                <span class="element-divider"></span>
                <ul class="element-menu">
                    <li>
                        <a class="dropdown-toggle">TRANG CHỦ</a>
                    </li>
                    <li>
                        <a class="dropdown-toggle">SUẤT CHIẾU</a>
                        <ul class="dropdown-menu dark" data-role="dropdown" style="display: none;">
                            <li>
                                <a href="~/Schedule">Theo rạp</a>
                            </li>
                            <li>
                                <a href="/">Theo phim</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a class="dropdown-toggle">PHIM</a>
                        <ul class="dropdown-menu dark" data-role="dropdown" style="display: none;">
                            <li>
                                <a href="/">Phim khuyến mãi</a>
                            </li>
                            <li>
                                <a href="/">Phim đang chiếu</a>
                            </li>
                            <li>
                                <a href="/">Phim sắp chiếu</a>
                            </li>
                            <li>
                                <a href="/">Phim Hot</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a class="dropdown-toggle">RẠP</a>
                        <ul class="dropdown-menu dark" data-role="dropdown" style="display: none;">
                            <li>
                                <a href="/">Rạp chiếu phim</a>
                            </li>
                            <li>
                                <a href="/">Cụm rạp</a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a class="dropdown-toggle">KHUYẾN MÃI</a>
                    </li>
                </ul>
                <div class="element place-right" style="position: absolute; right: 3px; z-index: 30; height: 2px">
                    @if (this.Session["RoleName"] == null)
                    {
                        <div style="overflow: auto;">
                            <button class="btn info" id="createFlatWindow" style="float: right; width: 100px; height: 30px; font-size: 15px; padding-top: 0px">Đăng Nhập</button>
                            <button class="btn success" style="float: right; width: 100px; height: 30px; font-size: 15px; padding-top: 0px">Đăng ký</button>
                        </div>
                    }
                    @if (this.Session["RoleName"] != null && this.Session["RoleName"].ToString().Trim() == "Customer")
                    {
                        <div style="font-size: large">
                            Chào @this.Session["Account"], <a href="#" style="color: orange; text-decoration: underline" onclick="LogOut()">Đăng Xuất</a>
                        </div>
                    }
                </div>

            </div>
        </div>

        <div style="margin-top: 115px">
            @RenderBody()
        </div>
    </div>
</body>
@*<script src="http://maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script> 
<script>
    var location1, location2;

    function getLocation() {
        // One-shot position request.
        navigator.geolocation.getCurrentPosition(callback);
    }

    function callback(position) {
        location1 = position;

        document.getElementById('latitude').innerHTML = position.coords.latitude;
        document.getElementById('longitude').innerHTML = position.coords.longitude;

        alert(getDistance(location1.coords.latitude, location1.coords.longitude, 10.773747, 106.694235))
    }

    function getDistance(lat1, lon1, lat2, lon2) {

        if (typeof (Number.prototype.toRad) === "undefined") {
            Number.prototype.toRad = function () {
                return this * Math.PI / 180;
            }
        }

        var R = 6371000; // m
        var dLat = (lat2 - lat1).toRad();
        var dLon = (lon2 - lon1).toRad();
        var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
            Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
            Math.sin(dLon / 2) * Math.sin(dLon / 2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        return R * c;
    }
</script>*@

<script>
    $(function () {
        $("#createFlatWindow").on('click', function () {
            $.Dialog({
                overlay: true,
                shadow: true,
                flat: true,
                title: 'Flat window',
                content: '',
                padding: 10,
                onShow: function (dialog) {
                    var content = '<label>Tên đăng nhập</label>' +
            '<div class="input-control text"><input type="text" name="userName" id="username"><button class="btn-clear"></button></div> ' +
        '<label>Mật khẩu </label>' + '<div class="input-control password">  <input type="password" name="password" id="password">     <button class="btn-reveal"></button></div> ' +
        '<div class="input-control checkbox">      <label><input type="checkbox" name="c1" checked/>        <span class="check"></span>Ghi nhớ</label></div>' +
         '<div class="form-actions">' +
        '<button class="button" onclick="checkLogin()">Đăng nhập</button> ' +
        '<button class="button" type="button" onclick="$.Dialog.close()">Đóng</button> ' +
        '</div>';
                    $.Dialog.title("Đăng Nhập");
                    $.Dialog.content(content);
                    $.Metro.initInputs();
                }
            });
        });
    });

    function checkLogin() {
        var username = $("#username").val();
        var password = $("#password").val();
        $.ajax({
            url: '/AccessPermission/CheckLogin',
            type: 'POST',
            data: { username: username, password: password },
            success: function (response) {
                if (response == "Customer") {
                    window.location.href = "Home/Customer";
                } else if (response == "Supplier") {
                    window.location.href = "";
                } else if (response == "Admin") {
                    window.location.href = "/Admin";
                } else if (response == "Staff") {
                    window.location.href = "/Film";
                } else {
                    alert("Tên đăng nhập hoặc mật khẩu chưa đúng!!!");
                }
            }
        });
    }

    //Logout-hungph
    function LogOut() {
        $.ajax({
            url: '/AccessPermission/LogOut',
            type: 'POST',
            success: function (response) {
                if (response == "Success") {
                    window.location.href = "/Home";
                } else {
                    alert("Không thể đăng xuất!!!");
                }
            }
        });
    }
</script>
</html>
